package com.lb.kugou;

import com.lb.view.MainContent;
import com.lb.view.MainMenuFragment;

import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.FrameLayout.LayoutParams;
import android.widget.LinearLayout;

public class MainActivity extends FragmentActivity {
	private MainMenuFragment mainMenu;
	public static int menu_margin_width = 0;
	public static int screenWidth = 0;
	private LinearLayout mainMenuParent;
	public MainContent mainContent;
 
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.main);
		if (screenWidth == 0)
			screenWidth = getWindowManager().getDefaultDisplay().getWidth();
		if (menu_margin_width == 0)
			menu_margin_width = BitmapFactory.decodeResource(getResources(), R.drawable.btn_title_navigation_default_theme_1).getHeight();
		getViewId();

		// setListViewAdapter();
	}

	public void onWindowFocusChanged(boolean hasFocus) {
		super.onWindowFocusChanged(hasFocus);
		mainMenu.notifyMenuChang();
	}

	public void getViewId() {
		mainMenu = (MainMenuFragment) getSupportFragmentManager().findFragmentById(R.id.main_menu);
		mainMenuParent = (LinearLayout) findViewById(R.id.main_menu_parent);
		mainMenuParent.setLayoutParams(new FrameLayout.LayoutParams(screenWidth-menu_margin_width,LayoutParams.MATCH_PARENT));
		mainContent = (MainContent) findViewById(R.id.main_content);
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}
	

}
